package cn.fl.project.service.impl;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.preloan.enums.LogBusinessTypeEnum;
import cn.fl.project.api.IPrjQuatPrpsApiService;
import cn.fl.project.condition.PrjQuatPrpsRebQueryCondition;
import cn.fl.project.dto.PrjQuatPrpsRebDTO;
import cn.fl.project.service.IPrjQuatPrpsRebService;
import cn.fl.project.transform.PrjQuatPrpsCfgMVOTransform;
import cn.fl.project.transform.PrjQuatPrpsRebVOTransform;
import cn.fl.project.vo.PrjQuatPrpsCfgMVO;
import cn.fl.project.vo.PrjQuatPrpsRebVO;
import com.lionbridge.log.ext.ExtSlf4jLogger;
import com.lionbridge.log.ext.ExtSlf4jLoggerBuilder;
import com.lionbridge.log.ext.LogTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 项目报价方案融资额返利配置表 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Slf4j
@Service
public class PrjQuatPrpsRebServiceImpl implements IPrjQuatPrpsRebService {
	private static ExtSlf4jLogger logger = ExtSlf4jLoggerBuilder.create()
			.setLogger(log).setBusinessType(LogBusinessTypeEnum.QUOTATION_SCHEME.getCode())
			.setSubBusinessType(LogBusinessTypeEnum.QUOTATION_SCHEME.getCode())
			.setLogType(LogTypeEnum.BUSINESS).build().setKeywords("PrjQuatPrpsPayReb");
	/**
	 * 项目报价方案配置API
	 */
	@Autowired
	private IPrjQuatPrpsApiService prjQuatPrpsApiService;

	@Override
	public PrjQuatPrpsRebVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			return null;
		}
		PrjQuatPrpsRebDTO dto = null;//this.自定义ApiService.selectById(id);
		return PrjQuatPrpsRebVOTransform.toVO(dto);
	}

	@Override
	public Long add(PrjQuatPrpsRebVO entity) throws BaseException{
		if(null == entity){
			return null;
		}
		//return this.prjQuatPrpsRebApiService.add(PrjQuatPrpsRebVOTransform.toDTO(entity));
		return null;
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			return false;
		}
		//return this.prjQuatPrpsRebApiService.removeById(id);
		return false;
	}
	
	/**
     * 删除
     * @param ids
     * @return
     */
    public boolean removeByIds(List<Long> ids)throws BaseException{
    	if(CollectionUtils.isEmpty(ids)){
			return false;
		};
		return false;
    }

	@Override
	public boolean modify(PrjQuatPrpsRebVO entity) throws BaseException{
		if(null == entity){
			return false;
		}
		//return this.prjQuatPrpsRebApiService.modify(PrjQuatPrpsRebVOTransform.toDTO(entity));
		return false;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page)page = new Pager();
		page = this.prjQuatPrpsApiService.searchPrjQuatPrpsRebeccaListPage(page, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
		List<PrjQuatPrpsRebDTO> DTOList = (List<PrjQuatPrpsRebDTO>) page.getResultList();
		page.setResultList(PrjQuatPrpsRebVOTransform.toVOList(DTOList));
		return page;
	}

	@Override
	public boolean batchAdd(PrjQuatPrpsCfgMVO entity) throws BaseException {
		if(null==entity || StringUtils.isEmpty(entity.getId())){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "项目报价方案主配置ID不能为空.");
		}
		return this.prjQuatPrpsApiService.batchAddPrjQuatPrpsReb(PrjQuatPrpsCfgMVOTransform.toDTO(entity));
	}

	@Override
	public List<PrjQuatPrpsRebVO> searchList(PrjQuatPrpsRebQueryCondition qc) throws BaseException {
		
		return PrjQuatPrpsRebVOTransform.toVOList(prjQuatPrpsApiService.searchPrjQuatPrpsRebList(qc));
	}
}
